import {useCallback} from 'react';
import {useSelector, useDispatch} from 'react-redux';
import goodstypeApi from '../api/goodstype';
import Creators from '../store/actions';
export const useGoodsType = () => {
  const goodstype = useSelector (state => state.goodstype);
  console.log(goodstype,"goodstype");
  const dispatch = useDispatch ();
  const getNavs = useCallback (
    async () => {
      const data = await goodstypeApi.get ();
      //  console.log("in");
      //    console.log(data);
      dispatch (Creators.getGoodsType (data));
    },
    [dispatch]
  );
  return [goodstype, {getNavs}];
};

